package server;

import java.net.ServerSocket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Simple serveur TCP creant des thread pour gerer chaque connexion client.
 * 
 * @author lom
 */
public class FTPServerMain {

    /**
     * Port d'ecoute.
     */
    public static final int PORT = 7802;
    /**
     * Socket serveur d'accueil.
     */
    
    public static void main(String argv[]) throws Exception 
    {
        ServerSocket socketaccueil=null;
        System.out.println("Server up and running.");
        FTPServer.setDebug(true);
        final ExecutorService executorPool = Executors.newFixedThreadPool(2);
        try{
            socketaccueil = new ServerSocket(PORT);
            for(;;){
                FTPServer server = new FTPServer(socketaccueil.accept());
                executorPool.submit(server);
            }
        } finally {
            if (socketaccueil != null) {
                    socketaccueil.close();
            }
        }
    }
}
